<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    

<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="keywords" content="服务器跑selenium监控课余量选课, 炫杉">
    <meta name="description" content="紫玉说课没选上，我就想写个脚本挂着看有没有退呗~

初探经过同学的推荐使用了selenium。做自动化测试很好啊，解决chekbox分分钟。开始啦~
上来就遇到问题了。要把geckodriver这个东西放到环境变量里。最后选择手动配置路径：">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>服务器跑selenium监控课余量选课 | 炫杉</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css">
<link rel="stylesheet" href="/css/prism-line-numbers.css" type="text/css"></head>

</head>

<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="container">
            <div class="nav-wrapper">
                <div class="brand-logo">
                    <a href="/" class="waves-effect waves-light">
                        
                        <img src="/medias/logo.png" class="logo-img hide-on-small-only">
                        
                        <span class="logo-span">炫杉</span>
                    </a>
                </div>
                <a href="#" data-activates="mobile-nav" class="button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>Index</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>Tags</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>Categories</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>Archives</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>About</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="https://oo1.win" class="waves-effect waves-light">
            
            <i class="fa fa-star"></i>
            
            <span>Bookmark</span>
        </a>
    </li>
    
    <li>
        <a id="toggleSearch" class="waves-effect waves-light">
            <i id="searchIcon" class="mdi-action-search"></i>
        </a>
    </li>

</ul>

<div class="side-nav" id="mobile-nav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">炫杉</div>
        <div class="logo-desc">
            
            提着鸟笼的老头站在一旁拍我肩膀 我猜他想的应该和我一样
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                Index
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                Tags
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                Categories
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                Archives
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                About
            </a>
        </li>
        
        <li>
            <a href="https://oo1.win" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-star"></i>
                
                Bookmark
            </a>
        </li>
        
        
    </ul>

    <div class="social-link"><a href="https://github.com/ixsim" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
    <i class="fa fa-github"></i>
</a>

<a href="mailto:chenjiayin1990@163.com" class="tooltipped" target="_blank" data-tooltip="邮件:chinalixs@qq.com" data-position="top" data-delay="50">
    <i class="fa fa-envelope-open"></i>
</a>

<a href="http://wpa.qq.com/msgrd?v=3&uin=6956820&site=qq&menu=yes" class="tooltipped" data-tooltip="QQ: 6956820" data-position="top" data-delay="50">
    <i class="fa fa-qq"></i>
</a>
</div>
</div>

            </div>
        </div>

        
    </nav>
</header>



<div class="bg-cover post-cover" style="background-image: url('/medias/featureimages/16.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        服务器跑selenium监控课余量选课
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1,
    #articleContent h2,
    #articleContent h3,
    #articleContent h4,
    #articleContent h5,
    #articleContent h6 {
        padding-top: 76px;
        margin-top: -76px;
    }

    #articleContent h1 {
        line-height: 3.5rem;
    }

    #articleContent h2 {
        line-height: 3.2rem;
    }

    #articleContent h3 {
        line-height: 2.8rem;
    }

    #articleContent h4 {
        line-height: 2.5rem;
    }

    #articleContent h5 {
        line-height: 2.2rem;
    }

    #articleContent h6 {
        line-height: 1.9rem;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }
</style>
<div class="row">
    <div class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            
            <div class="article-tag">
                
                <a href="/tags/Demo/" target="_blank">
                    <span class="chip bg-color">Demo</span>
                </a>
                
                <a href="/tags/Python/" target="_blank">
                    <span class="chip bg-color">Python</span>
                </a>
                
                <a href="/tags/Spider/" target="_blank">
                    <span class="chip bg-color">Spider</span>
                </a>
                
                <a href="/tags/selenium/" target="_blank">
                    <span class="chip bg-color">selenium</span>
                </a>
                
            </div>
            
            <div class="post-info">
                
                <span class="post-cate">
                    <i class="fa fa-bookmark fa-fw icon-category"></i>
                    
                    <a href="/categories/Python/" class="post-category" target="_blank">
                        Python
                    </a>
                    
                </span>
                

                <span class="post-date">
                    <i class="fa fa-clock-o fa-fw"></i>2018-05-22
                </span>
            </div>
        </div>
        <hr>
        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>紫玉说课没选上，我就想写个脚本挂着看有没有退呗~</p>
<a id="more"></a>
<h1 id="初探"><a href="#初探" class="headerlink" title="初探"></a>初探</h1><p>经过同学的推荐使用了selenium。做自动化测试很好啊，解决chekbox分分钟。开始啦~</p>
<p>上来就遇到问题了。要把<code>geckodriver</code>这个东西放到环境变量里。<br>最后选择手动配置路径：<br><code>dr = webdriver.Firefox(executable_path = &#39;/Users/lixs/anaconda3/geckodriver&#39;)</code><br>虽然麻烦点，但是着急往下写。我们继续~</p>
<p>先试试用Cookie登录</p>
<pre class="line-numbers language-Python"><code class="language-Python">driver.get('http://jwxk.ucas.ac.cn/courseManage/selectCourse?s=473bcdb8-8d5d-40af-9087-5071b63ff7a8')
#将用户名密码写入浏览器cookie中
driver.add_cookie({'name':'username','value':'chinalixs@qq.com'})
driver.add_cookie({'name':'pwd','value':'Jwsyb9503'})
#再次访问网站，将会自动登录
driver.get('http://jwxk.ucas.ac.cn/courseManage/')
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>不行，提示会话过期。先不用Cookie了以后再回来研究~自动填表吧~</p>
<pre class="line-numbers language-python"><code class="language-python"><span class="token comment" spellcheck="true"># login</span>
input <span class="token operator">=</span> driver<span class="token punctuation">.</span>find_element_by_name<span class="token punctuation">(</span><span class="token string">'userName'</span><span class="token punctuation">)</span>
input<span class="token punctuation">.</span>send_keys<span class="token punctuation">(</span><span class="token string">'NAME'</span><span class="token punctuation">)</span>
input <span class="token operator">=</span> driver<span class="token punctuation">.</span>find_element_by_name<span class="token punctuation">(</span><span class="token string">'pwd'</span><span class="token punctuation">)</span>
input<span class="token punctuation">.</span>send_keys<span class="token punctuation">(</span><span class="token string">'123456'</span><span class="token punctuation">)</span>
<span class="token comment" spellcheck="true">#点击登录</span>
sb <span class="token operator">=</span> driver<span class="token punctuation">.</span>find_element_by_name<span class="token punctuation">(</span><span class="token string">'sb'</span><span class="token punctuation">)</span><span class="token punctuation">.</span>click<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<p>然后选课找课都是一个模子的。只能说这个selenium很给力~</p>
<hr>
<h1 id="知识点"><a href="#知识点" class="headerlink" title="知识点"></a>知识点</h1><ul>
<li><p>嵌套找xpath:<br><code>driver.find_element_by_xpath(&#39;//form[@id=&quot;regfrm2&quot;]//button[@name=&quot;sb&quot;]&#39;).click()</code></p>
</li>
<li><p>time包 sleep(3) 等3秒做自动化测试很好用</p>
</li>
<li>处理弹窗：</li>
</ul>
<pre class="line-numbers language-python"><code class="language-python">al <span class="token operator">=</span> driver<span class="token punctuation">.</span>switch_to_alert<span class="token punctuation">(</span><span class="token punctuation">)</span>
time<span class="token punctuation">.</span>sleep<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span>
al<span class="token punctuation">.</span>accept<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
<ul>
<li>判断是否选上了<code>driver.find_element_by_xpath(&#39;//input[@value=&quot;65A7F68B98BB6FB9&quot;]&#39;).is_selected()</code></li>
</ul>
<hr>
<h1 id="实战本地跑"><a href="#实战本地跑" class="headerlink" title="实战本地跑"></a>实战本地跑</h1><p>截止到目前还是没选上的，因为没人退课啊。不过学到了selenium这个包。</p>
<p>具体思路就是监测那门课的 chekbox 前面的 √ 是否打上了，打不上就刷新，因为有了课余量那个 √ 是可以打上的，然后就一直刷新。<br>之前也是程序跑个20次左右就会报错，可能是请求太多了。然后刚好上次学到了 try/except ，哎呦不错哦。</p>
<h2 id="代码："><a href="#代码：" class="headerlink" title="代码："></a>代码：</h2><pre class="line-numbers language-Python"><code class="language-Python">from selenium import webdriver
import time

driver = webdriver.Firefox(executable_path = '/Users/lixs/anaconda3/geckodriver')
driver.get('http://sep.ucas.ac.cn')
# login
input = driver.find_element_by_name('userName')
input.send_keys('chinalixs@qq.com')
input = driver.find_element_by_name('pwd')
input.send_keys('Jwsyb9503')
sb = driver.find_element_by_name('sb').click()

# 打开选课系统
from selenium import webdriver
import time
driver = webdriver.Firefox(executable_path = '/Users/lixs/anaconda3/geckodriver')
driver.get('http://sep.ucas.ac.cn')
# login
input = driver.find_element_by_name('userName')
input.send_keys('chinalixs@qq.com')
input = driver.find_element_by_name('pwd')
input.send_keys('Jwsyb9503')
sb = driver.find_element_by_name('sb').click()
# 打开选课系统
driver.find_element_by_xpath('//a[@href="/portal/site/226/821"]').click()
# 点击选课
driver.get('http://jwxk.ucas.ac.cn/courseManage/main')
#选学院
driver.find_element_by_id('id_913').click()
driver.find_element_by_xpath('//form[@id="regfrm2"]//button[@name="sb"]').click()
#选课
i = 1
def xuanke(i):
    if i%100==0:
    #每当i跑100次就返回一下防止内存爆炸
        return
    try:
        driver.find_element_by_xpath('//input[@value="65A7F68B98BB6FB9"]').click()
        if driver.find_element_by_xpath('//input[@value="65A7F68B98BB6FB9"]').is_selected():
            print('选上啦！！！')
            return
        else:
            print(i,'次没选上继续')
            i += 1
            #刷新一下
            driver.refresh()
            al = driver.switch_to_alert()
            al.accept()
            xuanke(i)

    except:
        print('---------------ERROR---------------------')
        xuanke(i)
for a in range(10000):
    xuanke(i)
#提交
sb = driver.find_element_by_xpath('//button[@type="submit"]').click()
#弹出一个提示，选确定
sb = driver.find_element_by_xpath('//button[@value="ok"]').click()
print('OVER')
driver.close()
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h2 id="代码历史："><a href="#代码历史：" class="headerlink" title="代码历史："></a>代码历史：</h2><ul>
<li><strong>1.0版本</strong> 开始选课函数是 xuanke()<br>后来我想引入一个统计变量看跑了多少次。就在函数外设了个变量。结果很低级的错误就出现了，函数定义怎么能改全局变量i呢。真的天真</li>
<li><strong>2.0版本</strong> xuanke(i) 传入i。<br>统计可以了，新问题也就出现了。老版的 xuanke(i) 里每跑2k次左右，就会内存爆炸，于是</li>
<li><strong>3.0版本</strong> 每i==100就return一次。</li>
</ul>
<h1 id="服务器跑"><a href="#服务器跑" class="headerlink" title="服务器跑"></a>服务器跑</h1><p>频繁地去刷新网页，跑了一会儿课没选上，我16g的mac内存占用100%，开始发热了。于是服务器跑的思想直接就冒了出来~</p>
<p>刚好看到这篇文章：《<a href="https://www.cnblogs.com/bestruggle/p/8080983.html" target="_blank" rel="noopener">liunx centos7无GUI服务器跑Selenium部署说明》</a></p>
<h2 id="安装chrome"><a href="#安装chrome" class="headerlink" title="安装chrome"></a>安装chrome</h2><ol>
<li><p>添加chrome的repo源</p>
<pre><code>  vi /etc/yum.repos.d/google.repo
 [google]name=Google-x86_64baseurl=http://dl.google.com/linux/rpm/stable/x86_64enabled=1gpgcheck=0gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
</code></pre></li>
<li>安装<br><code>yum update</code> , 然后<code>yum install google-chrome-stable</code></li>
</ol>
<p><strong>注意</strong>：google-chrome一定一定不要用root用户去运行</p>
<h2 id="安装chromedrive"><a href="#安装chromedrive" class="headerlink" title="安装chromedrive"></a>安装chromedrive</h2><p>从<a href="https://sites.google.com/a/chromium.org/chromedriver/home" target="_blank" rel="noopener">https://sites.google.com/a/chromium.org/chromedriver/home</a> 下载 chromedriver</p>
<p>配置在PATH路径或者在脚本中指定路径  </p>
<pre><code>wget -N http://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip unzip chromedriver_linux64.zip

chmod +x chromedriver

sudo mv -f chromedriver /usr/local/share/chromedriver

sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver

sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
</code></pre><h2 id="安装Xvfb"><a href="#安装Xvfb" class="headerlink" title="安装Xvfb"></a>安装Xvfb</h2><p>无GUI时，Xvfb为虚拟GUI</p>
<pre class="line-numbers language-shell"><code class="language-shell">yum update

yum install Xvfb

yum -install libXfont

yum install xorg-x11-fonts*
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h2 id="安装selenium、pyvirtualdisplay"><a href="#安装selenium、pyvirtualdisplay" class="headerlink" title="安装selenium、pyvirtualdisplay"></a>安装selenium、pyvirtualdisplay</h2><p>pip install selenium</p>
<p>pip install pyvirtualdisplay</p>
<p>5.写个小demo测试下效果</p>
<p> vim test.py</p>
<pre class="line-numbers language-python"><code class="language-python"><span class="token keyword">from</span> selenium <span class="token keyword">import</span> webdriver
<span class="token keyword">from</span> pyvirtualdisplay <span class="token keyword">import</span> Display
　　

display <span class="token operator">=</span> Display<span class="token punctuation">(</span>visible<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span> size<span class="token operator">=</span><span class="token punctuation">(</span><span class="token number">800</span><span class="token punctuation">,</span><span class="token number">600</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
display<span class="token punctuation">.</span>start<span class="token punctuation">(</span><span class="token punctuation">)</span>
driver <span class="token operator">=</span> webdriver<span class="token punctuation">.</span>Chrome<span class="token punctuation">(</span><span class="token string">"./chromedriver"</span><span class="token punctuation">)</span>
driver<span class="token punctuation">.</span>get<span class="token punctuation">(</span><span class="token string">"http://www.baidu.com"</span><span class="token punctuation">)</span>
<span class="token keyword">print</span> driver<span class="token punctuation">.</span>page_source

driver<span class="token punctuation">.</span>quit<span class="token punctuation">(</span><span class="token punctuation">)</span>
display<span class="token punctuation">.</span>stop<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<blockquote>
<p>python test.py</p>
</blockquote>

            </div>
            <hr>

            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            <div class="reprint">
                <p>
                    <span class="reprint-tip">转载请注明: </span>
                    <a href="https://xuanshan.gitee.io" class="b-link-green">炫杉</a>
                    <i class="fa fa-angle-right fa-lg fa-fw text-color"></i>
                    <a href="/Python/监控课余量选课/" class="b-link-green">服务器跑selenium监控课余量选课</a>
                </p>
            </div>
        </div>
    </div>

    

    

    

    
    <div class="livere-card card" data-aos="fade-up">
    <!-- 来必力City版安装代码 -->
    <div id="lv-container" class="card-content" data-id="city" data-uid="MTAyMC8yOTg2My82NDI5">
        <script type="text/javascript">
            (function (d, s) {
                let j, e = d.getElementsByTagName(s)[0];
                if (typeof LivereTower === 'function') {
                    return;
                }

                j = d.createElement(s);
                j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
                j.async = true;

                e.parentNode.insertBefore(j, e);
            })(document, 'script');
        </script>
        <noscript>为正常使用来必力评论功能请激活JavaScript。</noscript>
    </div>
    <!-- City版安装代码已完成 -->
</div>
    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">上一篇</div>
            <div class="card">
                <a href="/Others/《移动安全与测评》Report/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/18.jpg" class="responsive-img" alt="《移动安全与测评》Report">
                        
                        <span class="card-title">《移动安全与测评》Report</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">只想双击666~

《移动安全与测评》报告
很喜欢移动开发，然后选了移动安全与测评这门课。课上学到很多移动安全的知识、思想。由于我对安卓开发没经验，也不是学安全专业的，对那个渗透测试的作业只能望而却步了。自己学了点iOS开发的皮毛，所以这篇</div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2018-05-26
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/Others/" class="post-category" target="_blank">
                                    Others
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">下一篇</div>
            <div class="card">
                <a href="/Python/爬一个520礼物给紫玉/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/21.jpg" class="responsive-img" alt="爬一个520礼物给紫玉">
                        
                        <span class="card-title">爬一个520礼物给紫玉</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">520送点啥呢。有Python不慌~哈哈我们来试着找一辆5月20号13点14的列车吧~

从分析到实践初探百度了下列车时刻表，有个ip138，就爬它啦🤭。先读一下第一页的内容：这网站太老了。竟然不是UTF-8编码的。解码：使用urlope</div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2018-05-18
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/Python/" class="post-category" target="_blank">
                                    Python
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Demo/" target="_blank">
                        <span class="chip bg-color">Demo</span>
                    </a>
                    
                    <a href="/tags/Python/" target="_blank">
                        <span class="chip bg-color">Python</span>
                    </a>
                    
                    <a href="/tags/Spider/" target="_blank">
                        <span class="chip bg-color">Spider</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>
    </div>
    <div class="col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title">目录</div>
            <div id="toc-content">

            </div>
        </div>
    </div>
</div>

<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingSelector: 'h1,h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h1,h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });
    });
</script>
    

</main>

<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            &copy;<a href="https://o--o.win" target="_blank">炫杉2018</a> 
            <a href="https://hexo.io/" target="_blank">Hexo</a> 强力驱动
              主题 <a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">matery</a>        </div>
        <div class="col s12 m4 l4 social-link"><a href="https://github.com/ixsim" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
    <i class="fa fa-github"></i>
</a>

<a href="mailto:chenjiayin1990@163.com" class="tooltipped" target="_blank" data-tooltip="邮件:chinalixs@qq.com" data-position="top" data-delay="50">
    <i class="fa fa-envelope-open"></i>
</a>

<a href="http://wpa.qq.com/msgrd?v=3&uin=6956820&site=qq&menu=yes" class="tooltipped" data-tooltip="QQ: 6956820" data-position="top" data-delay="50">
    <i class="fa fa-qq"></i>
</a>
</div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title">搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字" class="search-input" autofocus>
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/js/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>
</body>
</html>